package com.cooper.controllers;

import org.springframework.beans.factory.annotation.Autowired;

import com.cooper.entity.PageDetailEntity;
import com.cooper.entity.PagePanelEntity;
import com.cooper.service.admin.PageEditService;

import net.paoding.rose.web.Invocation;
import net.paoding.rose.web.annotation.Param;
import net.paoding.rose.web.annotation.rest.Get;

public class HelperController {
	
	@Autowired
	private PageEditService pageEditService;
	
	@Get("pagePanel")
	public String pagePanel(Invocation inv, @Param("pageKey") String pageKey) throws Exception{
		PagePanelEntity pagePanel = this.pageEditService.getPagePanelByKey(pageKey);
		if(null != pagePanel){
			return "@" + pagePanel.getContent();
		}
		return "@";
	}

	@Get("pageDetail")
	public String pageDetail(Invocation inv, @Param("detailId") long detailId) throws Exception{
		PageDetailEntity pageDetail = this.pageEditService.getPageDetailById(detailId);
		inv.addModel("entity", pageDetail);
		return "PageDetail";
	}
}
